<template>
	<!-- 教练申请 -->
	<view class="form-page" v-if="coachinfo == null">
		<view class="form-title">教练申请</view>
		<view class="form-item">
			<text>绑定门店（必选）</text>
			<picker mode="selector" :range="shopList" range-key="shop_name" @change="onShopChange">
				<view class="picker">
					{{ selectedShopName || '请选择绑定门店' }}
				</view>
			</picker>
		</view>

		<view class="form-item"><text>姓名（必填）</text><input v-model="form.name" placeholder="请输入姓名" /></view>
		<view class="form-item"><text>电话（必填）</text><input v-model="form.phone" placeholder="请输入电话" type="number" disabled="true"/></view>
		<view class="form-item"><text>年龄</text><input v-model="form.age" placeholder="请输入年龄" type="number" /></view>

		<view class="form-item">
			<text>性别</text>
			<picker :range="sexOptions" :value="form.sex" @change="e => form.sex = e.detail.value">
				<view class="picker">{{ sexOptions[form.sex] }}</view>
			</picker>
		</view>
		<view class="form-item">
			<text>个人标签</text>
			<picker mode="selector" :range="lableList" range-key="lable_name" @change="onLableChange">
				<view class="picker">
					{{ selectedLableName || '请选择标签' }}
				</view>
			</picker>
		</view>
		<view class="form-item">
			<text>头像（必传）</text>
			<view class="upload-box">
				<view v-if="form.coach_avatar" class="img-wrap">
					<image :src="web_url + form.coach_avatar" class="img" mode="aspectFill"></image>
					<view class="delete-btn" @click="form.coach_avatar = ''">×</view>
				</view>
				<view v-else class="add-btn" @click="chooseImage('coach_avatar')">+</view>
			</view>
		</view>
		<view class="form-item">
			<text>身份证正面（必传）</text>
			<view class="upload-box">
				<view v-if="form.idcard_front" class="img-wrap">
					<image :src="web_url + form.idcard_front" class="img" mode="aspectFill"></image>
					<view class="delete-btn" @click="form.idcard_front = ''">×</view>
				</view>
				<view v-else class="add-btn" @click="chooseImage('idcard_front')">+</view>
			</view>
		</view>
		
		<view class="form-item">
			<text>身份证背面（必传）</text>
			<view class="upload-box">
				<view v-if="form.idcard_back" class="img-wrap">
					<image :src="web_url + form.idcard_back" class="img" mode="aspectFill"></image>
					<view class="delete-btn" @click="form.idcard_back = ''">×</view>
				</view>
				<view v-else class="add-btn" @click="chooseImage('idcard_back')">+</view>
			</view>
		</view>
		<view class="form-item">
			<text>个人图集（最多 5 张）</text>
			<view class="upload-box">
				<block v-for="(img, index) in form.coach_images" :key="index">
					<view class="img-wrap">
						<image :src="web_url + img" mode="aspectFill" class="img" />
						<view class="delete-btn" @click="removeCoachImage(index)">×</view>
					</view>
				</block>
				<view v-if="form.coach_images.length < 5" class="add-btn" @click="chooseCoachImages">+</view>
			</view>
		</view>

		<!-- 	<view class="form-item">
			<text class="label">资格证书：</text>
			<view class="upload-box">
				<view class="img-wrap" v-if="form.cert">
					<image :src="web_url + form.cert" class="img" />
					<text class="delete-btn" @click="removeCertImage">×</text>
				</view>
				<view class="add-btn" v-else @click="chooseCertImage">+</view>
			</view>
		</view> -->
		
		<view class="form-item">
			<text class="label">资格证书：</text>
			<view class="upload-box">
				<view class="img-wrap" v-for="(img, idx) in form.cert" :key="idx">
					<image :src="web_url + img" class="img" />
					<text class="delete-btn" @click="removeCertImage(idx)">×</text>
				</view>
				<view class="add-btn" v-if="form.cert.length<5" @click="chooseCertImage">+</view>
			</view>
		</view>
		<view class="form-item">
			<text class="label">教学照片：</text>
			<view class="upload-box">
				<view class="img-wrap" v-for="(img, idx) in form.teach_imgs" :key="idx">
					<image :src="web_url + img" class="img" />
					<text class="delete-btn" @click="removeTeachImage(idx)">×</text>
				</view>
				<view class="add-btn" v-if="form.teach_imgs.length<5" @click="chooseTeachImage">+</view>
			</view>
		</view>

		<view class="form-item">
			<text class="label">教学视频：</text>
			<view class="upload-box">
				<view class="img-wrap" v-for="(v, idx) in form.teach_videos" :key="idx">
					<video :src="web_url + v" class="video" controls />
					<text class="delete-btn" @click="removeTeachVideo(idx)">×</text>
				</view>
				<view class="add-btn" v-if="form.teach_videos.length<5" @click="chooseTeachVideo">+</view>
			</view>
		</view>
		<view class="form-item">
			<text>教练简介</text>
			<textarea v-model="form.coach_info" placeholder="请输入教练简介" />
		</view>
		
		<view class="form-item">
			<text>专业特长</text>
			<textarea v-model="form.skill" placeholder="请输入专业特长" />
		</view>
		<view class="form-item">
			<text>教学特色</text>
			<textarea v-model="form.feature" placeholder="请输入教学特色" />
		</view>
		<view class="form-item"><text>工作经历</text><textarea v-model="form.work_exp" placeholder="请输入工作经历" /></view>
		<view class="form-item"><text>教育经历</text><textarea v-model="form.edu_exp" placeholder="请输入教育经历" /></view>
		
		<button class="form-btn" @click="submit">提交申请</button>
	</view>
	
	
	
	
	
	<!-- 审核中 -->
	<view  v-else-if="coachinfo != null&&coachinfo.state==1">
		<view class="form-title" style="color:#fff;margin: 0px;font-size:32rpx;padding:10rpx 0px;background:#FFCF00;">审核中</view>
		<view class="form-page">
			<view class="form-item"><text>姓名</text><input v-model="coachinfo.coach_name" placeholder="请输入姓名" disabled="true"/></view>
			<view class="form-item"><text>电话</text><input v-model="coachinfo.coach_mobile" placeholder="请输入电话" type="number" disabled="true"/></view>
			<view class="form-item"><text>年龄</text><input v-model="coachinfo.coach_age" placeholder="请输入年龄" type="number" disabled="true"/></view>
		
			<view class="form-item">
				<text>性别</text>
				<!-- <picker :range="sexOptions" :value="coachinfo.sex" @change="e => coachinfo.sex = e.detail.value"> -->
					<view class="picker">{{coachinfo.coach_sex=='male'?'男':'女'}}</view>
				<!-- </picker> -->
			</view>

			<view class="form-item">
				<text>教练简介</text>
				<textarea v-model="coachinfo.coach_info" placeholder="请输入教练简介" disabled="true" />
			</view>
		
			<view class="form-item">
				<text>专业特长</text>
				<textarea v-model="coachinfo.talent" placeholder="请输入专业特长" disabled="true"/>
			</view>
			<view class="form-item">
				<text>教学特色</text>
				<textarea v-model="coachinfo.trait" placeholder="请输入教学特色" disabled="true"/>
			</view>
			<view class="form-item"><text>工作经历</text><textarea v-model="coachinfo.work" placeholder="请输入工作经历" disabled="true"/></view>
			<view class="form-item"><text>教育经历</text><textarea v-model="coachinfo.teach" placeholder="请输入教育经历" disabled="true"/></view>
		
			<!-- 	<view class="form-item">
				<text class="label">资格证书：</text>
				<view class="upload-box">
					<view class="img-wrap" v-if="form.cert">
						<image :src="web_url + form.cert" class="img" />
						<text class="delete-btn" @click="removeCertImage">×</text>
					</view>
					<view class="add-btn" v-else @click="chooseCertImage">+</view>
				</view>
			</view> -->
			<view class="form-item">
				<text>身份证照片（正面）</text>
				<view class="upload-box">
					<view v-if="coachinfo.idcard_add" class="img-wrap">
						<image :src="web_url + coachinfo.idcard_add" class="img" mode="aspectFill"></image>
						<!-- <view class="delete-btn" @click="coachinfo.idcard_add = ''">×</view> -->
					</view>
					<!-- <view v-else class="add-btn" @click="chooseImage('idcard_add')">+</view> -->
				</view>
			</view>
			
			<view class="form-item">
				<text>身份证照片（背面）</text>
				<view class="upload-box">
					<view v-if="coachinfo.idcard_cut" class="img-wrap">
						<image :src="web_url + coachinfo.idcard_cut" class="img" mode="aspectFill"></image>
						<!-- <view class="delete-btn" @click="coachinfo.idcard_cut = ''">×</view> -->
					</view>
					<!-- <view v-else class="add-btn" @click="chooseImage('idcard_cut')">+</view> -->
				</view>
			</view>
			<view class="form-item">
				<text class="label">资格证书：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(img, idx) in coachinfo.prove_images" :key="idx">
						<image :src="web_url + img" class="img" />
						<!-- <text class="delete-btn" @click="removeCertImage(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.prove_images.length<5" @click="chooseCertImage">+</view> -->
				</view>
			</view>
			<view class="form-item">
				<text class="label">教学照片：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(img, idx) in coachinfo.teach_images" :key="idx">
						<image :src="web_url + img" class="img" />
						<!-- <text class="delete-btn" @click="removeTeachImage(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.teach_imgs.length<5" @click="chooseTeachImage">+</view> -->
				</view>
			</view>
		
			<view class="form-item">
				<text class="label">教学视频：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(v, idx) in coachinfo.teach_videos" :key="idx">
						<video :src="web_url + v" class="video" controls />
						<!-- <text class="delete-btn" @click="removeTeachVideo(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.teach_videos.length<5" @click="chooseTeachVideo">+</view> -->
				</view>
			</view>
			<button class="form-btn" @click="cxshenqing">正在审核，请稍等</button>
		</view>
	</view>
	
	
	
	
	
	
	<!-- 审核已驳回 -->
	<view  v-else-if="coachinfo != null&&coachinfo.state==3">
		<view class="form-title" style="color:#fff;margin: 0px;font-size:32rpx;padding:10rpx 0px;background:red;" @click="cxshenqing">审核已驳回，请重新提交</view>
		<view class="form-title" style="margin: 0px;background-color: #181818;font-size: 24rpx;padding: 5px 0px;">驳回原因：{{ coachinfo.reason }}</view>
		<view class="form-page">
			<view class="form-item"><text>姓名</text><input v-model="coachinfo.coach_name" placeholder="请输入姓名" disabled="true"/></view>
			<view class="form-item"><text>电话</text><input v-model="coachinfo.coach_mobile" placeholder="请输入电话" type="number" disabled="true"/></view>
			<view class="form-item"><text>年龄</text><input v-model="coachinfo.coach_age" placeholder="请输入年龄" type="number" disabled="true"/></view>
		
			<view class="form-item">
				<text>性别</text>
				<!-- <picker :range="sexOptions" :value="coachinfo.sex" @change="e => coachinfo.sex = e.detail.value"> -->
					<view class="picker">{{coachinfo.coach_sex=='male'?'男':'女'}}</view>
				<!-- </picker> -->
			</view>

			<view class="form-item">
				<text>教练简介</text>
				<textarea v-model="coachinfo.coach_info" placeholder="请输入教练简介" disabled="true" />
			</view>
		
			<view class="form-item">
				<text>专业特长</text>
				<textarea v-model="coachinfo.talent" placeholder="请输入专业特长" disabled="true"/>
			</view>
			<view class="form-item">
				<text>教学特色</text>
				<textarea v-model="coachinfo.trait" placeholder="请输入教学特色" disabled="true"/>
			</view>
			<view class="form-item"><text>工作经历</text><textarea v-model="coachinfo.work" placeholder="请输入工作经历" disabled="true"/></view>
			<view class="form-item"><text>教育经历</text><textarea v-model="coachinfo.teach" placeholder="请输入教育经历" disabled="true"/></view>
		
			<!-- 	<view class="form-item">
				<text class="label">资格证书：</text>
				<view class="upload-box">
					<view class="img-wrap" v-if="form.cert">
						<image :src="web_url + form.cert" class="img" />
						<text class="delete-btn" @click="removeCertImage">×</text>
					</view>
					<view class="add-btn" v-else @click="chooseCertImage">+</view>
				</view>
			</view> -->
			<view class="form-item">
				<text>身份证照片（正面）</text>
				<view class="upload-box">
					<view v-if="coachinfo.idcard_add" class="img-wrap">
						<image :src="web_url + coachinfo.idcard_add" class="img" mode="aspectFill"></image>
						<!-- <view class="delete-btn" @click="coachinfo.idcard_add = ''">×</view> -->
					</view>
					<!-- <view v-else class="add-btn" @click="chooseImage('idcard_add')">+</view> -->
				</view>
			</view>
			
			<view class="form-item">
				<text>身份证照片（背面）</text>
				<view class="upload-box">
					<view v-if="coachinfo.idcard_cut" class="img-wrap">
						<image :src="web_url + coachinfo.idcard_cut" class="img" mode="aspectFill"></image>
						<!-- <view class="delete-btn" @click="coachinfo.idcard_cut = ''">×</view> -->
					</view>
					<!-- <view v-else class="add-btn" @click="chooseImage('idcard_cut')">+</view> -->
				</view>
			</view>
			
			<view class="form-item">
				<text class="label">资格证书：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(img, idx) in coachinfo.prove_images" :key="idx">
						<image :src="web_url + img" class="img" />
						<!-- <text class="delete-btn" @click="removeCertImage(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.prove_images.length<5" @click="chooseCertImage">+</view> -->
				</view>
			</view>
			<view class="form-item">
				<text class="label">教学照片：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(img, idx) in coachinfo.teach_images" :key="idx">
						<image :src="web_url + img" class="img" />
						<!-- <text class="delete-btn" @click="removeTeachImage(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.teach_imgs.length<5" @click="chooseTeachImage">+</view> -->
				</view>
			</view>
		
			<view class="form-item">
				<text class="label">教学视频：</text>
				<view class="upload-box">
					<view class="img-wrap" v-for="(v, idx) in coachinfo.teach_videos" :key="idx">
						<video :src="web_url + v" class="video" controls />
						<!-- <text class="delete-btn" @click="removeTeachVideo(idx)">×</text> -->
					</view>
					<!-- <view class="add-btn" v-if="coachinfo.teach_videos.length<5" @click="chooseTeachVideo">+</view> -->
				</view>
			</view>
			<button class="form-btn" @click="cxshenqing" style="background-color: red;color: #fff;">审核已驳回，重新提交</button>
		</view>
	</view>
	
	
	
	
	
	
</template>
<script>
	import uploads from "@/util/upload.js";
	const webConfig = require("@/util/config");
	const app = getApp();
	export default {
		data() {
			return {
				sexOptions: ['男', '女'],
				form: {
					idcard_front: '',
					idcard_back: '',
					name: '',
					phone: '',
					age: '',
					sex: 0,
					skill: '',
					feature: '',
					work_exp: '',
					edu_exp: '',
					coach_info: '',
					cert: [],
					teach_imgs: [],
					teach_videos: [],
					coach_avatar:'',
					coach_images:[],
					shop_id:-1,
					lable_id:-1,
					selectedShopIndex:0,
					selectedLableIndex:0,
				},
				selectedShopName:null,
				selectedLableName:null,
				city_id:0,
				shopList:[],
				lableList:[],
				coachinfo:null,
				uploading: false,
				web_url: ''
			};
		},
		onLoad() {
			this.city_id = app.globalData.cityInfo.id || 0;
			this.web_url = webConfig.base_url || '';
			console.log(111)
			this.getUserInfo();
			this.getShopList();
			this.getLableList();
		},
		methods: {
			//获取门店列表
			getShopList() {
				let _this = this;
				this.$http({
					url: '/addons/xilufitness/shop/index2',
					data: {
						page: _this.page,
						lat: app.globalData.lat,
						lng: app.globalData.lng,
						city_id: _this.city_id,
						keywords: ""
					},
					method: 'get'
				}).then(res => {
					_this.shopList = res.data;
				}).catch(error => {
					console.log('shopListError', error);
				});
			},
			//获取门店列表
			getLableList() {
				let _this = this;
				this.$http({
					url: '/addons/xilufitness/coach/lableList',
					data: {
					},
					method: 'get'
				}).then(res => {
					_this.lableList = res.data;
				}).catch(error => {
					console.log('lableListError', error);
				});
			},
			chooseCoachImages() {
				let _this = this;
				const maxCount = 5 - this.form.coach_images.length;
				if (maxCount <= 0) return;
				uni.chooseImage({
					count: maxCount,
					success(res) {
						const tempFiles = res.tempFilePaths;
						let uploadCount = 0;
						uni.showLoading({
							title: '上传中...'
						});
						tempFiles.forEach(tempPath => {
							uploads.uploadFile(tempPath, function(uploadRes) {
								uploadCount++;
								if (uploadRes.code === 1) {
									_this.form.coach_images.push(uploadRes.data.url);
								} else {
									uni.showToast({
										title: uploadRes.msg || '上传失败',
										icon: 'none'
									});
								}
								if (uploadCount === tempFiles.length) {
									uni.hideLoading();
								}
							});
						});
					}
				});
			},
			chooseImage(field) {
				let _this = this;
				uni.chooseImage({
					count: 1,
					success(res) {
						const tempPath = res.tempFilePaths[0];
						uni.showLoading({
							title: '上传中...'
						});
						uploads.uploadFile(tempPath, function(uploadRes) {
							uni.hideLoading();
							if (uploadRes.code === 1) {
								_this.form[field] = uploadRes.data.url;
							} else {
								uni.showToast({
									title: uploadRes.msg || '上传失败',
									icon: 'none'
								});
							}
						});
					}
				});
			},
		
		getUserInfo() {
			let _this = this;
			this.$http({
				url: '/addons/xilufitness/user/index',
				method: 'get'
			}).then(res => {
				if (res.code == 1) {
					_this.form.phone = res.data.info.mobile;
					_this.coachinfo = res.data.info.coachinfo;
					_this.coachinfo.prove_images=_this.coachinfo.prove_images.split(",");
					_this.coachinfo.teach_images=_this.coachinfo.teach_images.split(",");
					_this.coachinfo.teach_videos=_this.coachinfo.teach_videos.split(",");
					_this.coachinfo.coach_images=_this.coachinfo.coach_images.split(",");
				} 
			}).catch(error => {
				console.log('userError', error);
			})
		},
		
			onShopChange(e) {
				const index = e.detail.value;
				const selected = this.shopList[index];
				this.selectedShopIndex = index;
				this.form.shop_id = selected.id;
				this.selectedShopName = selected.shop_name;
			},
			onLableChange(e) {
				const index = e.detail.value;
				const selected = this.lableList[index];
				this.selectedLableIndex = index;
				this.form.lable_id = selected.id;
				this.selectedLableName = selected.lable_name;
			},
			chooseCertImage() {
			  let _this = this;
			  let max = 5 - this.form.cert.length;
			  if (max <= 0) return;
			  uni.chooseImage({
			    count: max,
			    success(res) {
			      let tempFiles = res.tempFilePaths;
			      let uploadCount = 0;
			      uni.showLoading({ title: '上传中' });
			      tempFiles.forEach((tempPath) => {
			        uploads.uploadFile(tempPath, function(uploadRes) {
			          uploadCount++;
			          if (uploadRes.code === 1) {
			            _this.form.cert.push(uploadRes.data.url);
			          } else {
			            uni.showToast({
			              title: uploadRes.msg || '上传失败',
			              icon: 'none'
			            });
			          }
			          if (uploadCount === tempFiles.length) {
			            uni.hideLoading();
			          }
			        });
			      });
			    }
			  });
			},
			removeCertImage(idx) {
			  this.form.cert.splice(idx, 1);
			},
			removeCoachImage(index) {
				this.form.coach_images.splice(index, 1);
			},
			chooseMultiImage(field) {
				let _this = this;
				uni.chooseImage({
					count: 1,
					success(res) {
						let tempPath = res.tempFilePaths[0];
						// uni.showLoading({title: '上传中'});
						uploads.uploadFile(tempPath, function(uploadRes, uploadTask) {
							uni.hideLoading();
							if (uploadRes.code == 1) {
								_this.form[field] = uploadRes.data.url;
							} else {
								uni.showToast({
									title: uploadRes.msg || '上传失败',
									icon: 'none'
								});
							}
						});
					}
				});
			},

			// 上传教学图片
			chooseTeachImage() {
				let _this = this;
				let max = 5 - this.form.teach_imgs.length;
				if (max <= 0) return;
				uni.chooseImage({
					count: max,
					success(res) {
						let tempFiles = res.tempFilePaths;
						let uploadCount = 0;
						uni.showLoading({
							title: '上传中'
						});
						tempFiles.forEach((tempPath, idx) => {
							uploads.uploadFile(tempPath, function(uploadRes, uploadTask) {
								uploadCount++;
								if (uploadRes.code == 1) {
									_this.form.teach_imgs.push(uploadRes.data.url);
								} else {
									uni.showToast({
										title: uploadRes.msg || '上传失败',
										icon: 'none'
									});
								}
								if (uploadCount === tempFiles.length) {
									uni.hideLoading();
								}
							});
						});
					}
				});
			},
			removeTeachImage(index) {
				this.form.teach_imgs.splice(index, 1);
			},

			chooseTeachVideo() {
				let _this = this;
				if (this.form.teach_videos.length >= 5) {
					uni.showToast({
						title: '最多上传5个视频',
						icon: 'none'
					});
					return;
				}
				uni.chooseVideo({
					sourceType: ['camera', 'album'],
					success: (res) => {
						let tempPath = res.tempFilePath;
						uni.showLoading({
							title: '上传中'
						});
						uploads.uploadFile(tempPath, function(uploadRes, uploadTask) {
							uni.hideLoading();
							if (uploadRes.code == 1) {
								_this.form.teach_videos.push(uploadRes.data.url);
							} else {
								uni.showToast({
									title: uploadRes.msg || '上传失败',
									icon: 'none'
								});
							}
						});
					}
				});
			},
			removeTeachVideo(index) {
				this.form.teach_videos.splice(index, 1);
			},
			
			//重新提交申请
			cxshenqing() {
				this.coachinfo = null;
			},
			//提交申请
			submit() {
				// 校验（可以根据需要自行加严谨）
				if (!this.form.name){
					uni.showToast({
						title: '请完善姓名',
						icon: 'none'
					});
					return;
				}
				if (!this.form.phone){
					uni.showToast({
						title: '请填写电话',
						icon: 'none'
					});
					return;
				}
				if (!this.form.idcard_front){
					uni.showToast({
						title: '请上传身份证正面照片',
						icon: 'none'
					});
					return;
				}
				if (!this.form.idcard_back){
				 	uni.showToast({
				 		title: '请上传身份证背面照片',
				 		icon: 'none'
				 	});
				 	return;
				}
				if (!this.form.shop_id){
				 	uni.showToast({
				 		title: '请选择所属店铺',
				 		icon: 'none'
				 	});
				 	return;
				}
				
				const sexText = this.sexOptions[this.form.sex];
				const sexValue = sexText === '男' ? 'male' : 'female';
				let _this = this
				this.$http({
					url: '/addons/xilufitness/coach/apply',
					method: 'POST',
					data: {
						coach_name: this.form.name,
						coach_mobile: this.form.phone,
						coach_age: this.form.age,
						coach_sex: sexValue,
						idcard_add: this.form.idcard_front,
						idcard_cut: this.form.idcard_back,
						talent: this.form.skill,
						trait: this.form.feature,
						work: this.form.work_exp,
						coach_info: this.form.coach_info,
						teach: this.form.edu_exp,
						prove_images: this.form.cert,
						teach_images: this.form.teach_imgs, // 直接数组
						teach_videos: this.form.teach_videos ,// 直接数组
						shop_ids: this.form.shop_id ,// 直接数组
						coach_images: this.form.coach_images,
						coach_avatar: this.form.coach_avatar,
						lable_ids:this.form.lable_id
						// teach_videos: ['uploads/20250722/c3f0e052e7316ccea156d7ceea1fdf59.mp4'] // 直接数组
					}
				}).then(res => {
					let code = res.code
					uni.showToast({
						title: res.msg,
						icon: 'success',
						duration: 3000,
						success() {
							console.log(code);
							console.log(_this.$api);
							if (code == 1) {
								_this.$api.navigate("../mine/mine")
							}
						}
					});



				}).catch(err => {
					uni.showToast({
						title: err.msg || '提交失败',
						icon: 'none'
					});
				});
			}
		}
	};
</script>
<style scoped>
	.form-page {
		background-color: #E8EEFE;
		min-height: 100vh;
		padding: 30rpx;
		color: #fff;
		box-sizing: border-box;
	}

	.form-title {
		font-size: 40rpx;
		color: #FFCF00;
		margin-bottom: 40rpx;
		text-align: center;
		font-weight: bold;
	}

	.form-item {
		margin-bottom: 40rpx;
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.form-item text {
		color: #333;
		font-size: 28rpx;
		font-weight: 500;
	}

	input,
	textarea {
		background-color: #fff;
		color: #333;
		border: 1px solid #E8EEFE;
		border-radius: 12rpx;
		width: 92%;
		padding: 24rpx;
		font-size: 28rpx;
		box-sizing: content-box;
		transition: 0.2s;
	}

	input:focus,
	textarea:focus {
		border-color: #FFCF00;
		box-shadow: 0 0 10rpx rgba(255, 207, 0, 0.5);
		outline: none;
	}

	textarea {
		min-height: 120rpx;
		line-height: 1.5;
		resize: none;
	}

	.picker {
		background-color: #fff;
		color: #333;
		border: 1px solid #E8EEFE;
		border-radius: 12rpx;
		padding: 24rpx;
		font-size: 28rpx;
		transition: 0.2s;
	}

	.picker:active {
		border-color: #FFCF00;
		box-shadow: 0 0 10rpx rgba(255, 207, 0, 0.5);
	}

	.upload-box {
		display: flex;
		gap: 20rpx;
		flex-wrap: wrap;
	}

	.img-wrap {
		position: relative;
		width: 160rpx;
		height: 160rpx;
		border-radius: 12rpx;
		overflow: hidden;
	}

	.img,
	.video {
		width: 100%;
		height: 100%;
		object-fit: cover;
		border-radius: 12rpx;
	}

	.delete-btn {
		position: absolute;
		top: 0;
		right: 0;
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		text-align: center;
		background: rgba(0, 0, 0, 0.5);
		color: #fff;
		border-bottom-left-radius: 12rpx;
		font-size: 30rpx;
	}

	.add-btn {
		width: 160rpx;
		height: 160rpx;
		background-color: #fff;
		color: #999;
		font-size: 60rpx;
		text-align: center;
		line-height: 160rpx;
		border-radius: 12rpx;
	}

	.form-btn {
		background-color: #FFCF00;
		color: #181818;
		border-radius: 16rpx;
		font-size: 32rpx;
		width: 90%;
		margin: 60rpx auto 0;
		display: block;
		text-align: center;
		padding: 24rpx 0;
		box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.4);
		transition: 0.2s;
	}

	.form-btn:active {
		transform: scale(0.96);
		opacity: 0.8;
	}
</style>